﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using org.iringtools.library;
using System.Data;
using org.iringtools.utility;
using System.Runtime.Serialization;
using System.IO;
using NHibernate.Cfg;
using NInjectTest;
using org.iringug.iringtools.test;

namespace IRINGAdapter
{
  class Program
  {
    static void Main(string[] args)
    {
      AdapterService adapterService = new AdapterService();

      string path = @"C:\Development\VS08 Projects\IRINGAdapter\IRINGAdapter\DatabaseDictionary.xml";
      DatabaseDictionary dbDictionary = Utility.Read<DatabaseDictionary>(path);

      string appName = adapterService.PostDatabaseDictionary(dbDictionary);
      List<Person> persons = adapterService.GetList<Person>(appName);
      foreach (Person person in persons)
      {
        Console.WriteLine(person.Name);
      }
      
      Console.Write("\nPress any key to continue ...");
      Console.ReadKey();
    }
  }
}

/*
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate" />
  </configSections>
  <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
    <!-- Oracle configuration -->
    <!--
    <session-factory>
      <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
      <property name="connection.driver_class">NHibernate.Driver.OracleClientDriver</property>
      <property name="connection.connection_string">user id=em; password=em; data source=localdb; persist security info=true</property>
      <property name="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle</property>
      <property name="dialect">NHibernate.Dialect.Oracle10gDialect</property>
      <property name="show_sql">false</property>
    </session-factory>
    -->

    <!-- MS Sql Server configuration -->
    <session-factory>
      <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
      <property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
      <property name="connection.connection_string">Data Source=.\SQLEXPRESS;Initial Catalog=hibernate;User Id=hibernate;Password=hibernate;</property>
      <property name="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle</property>
      <property name="dialect">NHibernate.Dialect.MsSql2008Dialect</property>
      <property name="show_sql">false</property>

      <!--<mapping assembly="org.iringug.iringtools.hibernatetest"/>-->

    </session-factory>
  </hibernate-configuration>
</configuration>
*/

/*
Configuration config = new Configuration();
IDictionary props = new Hashtable();
String connectionString = "Server=server;Database=dbName;User ID=user;Password=passwd";
props.Add("hibernate.dialect", "NHibernate.Dialect.MySQLDialect");
props.Add("hibernate.connection.provider", "NHibernate.Connection.DriverConnectionProvider");
props.Add("hibernate.connection.driver_class", "NHibernate.Driver.MySqlDataDriver");
props.Add("hibernate.connection.connection_string", connectionString);
config.AddProperties(props);
config.AddFile("Dummy.hbm.xml");
ISessionFactory factory = config.BuildSessionFactory();
ISession session = factory.OpenSession();
*/
